package com.bigmi.wemedia.controller.v1;

import com.bigmi.model.common.dtos.ResponseResult;
import com.bigmi.model.wemedia.dtos.WmNewsPageReqDto;
import com.bigmi.model.wemedia.dtos.WmNewsDto;
import com.bigmi.wemedia.service.WmNewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/news")
public class WmNewsController {
    @Autowired
    private WmNewsService wmNewsService;

    @PostMapping("/list")
    public ResponseResult findList(@RequestBody WmNewsPageReqDto wmNewsPageReqDto){
        return wmNewsService.findList(wmNewsPageReqDto);
    }
    @PostMapping("/submit")
    public ResponseResult submit(@RequestBody WmNewsDto wmNewsDto){
        return wmNewsService.submit(wmNewsDto);
    }
    //编辑查看文章
    @GetMapping("/one/{id}")
    public ResponseResult one(@PathVariable int id){
        return wmNewsService.one(id);
    }
    //删除文章
    @GetMapping("/del_news/{id}")
    public ResponseResult del_news(@PathVariable int id){
        return wmNewsService.del_news(id);
    }
    //上下架操作
    @PostMapping("/down_or_up")
    public ResponseResult down_or_up(@RequestBody WmNewsDto wmNewsDto){
            return wmNewsService.down_or_up(wmNewsDto);
    }

}
